/*
 *  macread.c
 *  ratmac
 *
 *  Created by Torsten Kammer on 20.01.08.
 *  Copyright 2008 Ferroequinologist.de. All rights reserved.
 *
 */

#include "macread.h"
#include <CoreFoundation/CoreFoundation.h>
#include <sys/stat.h>

int readu32(unsigned long *target, FILE *fp)
{
	int result = fread(target, 4, 1, fp);
	*target = CFSwapInt32LittleToHost(*target);
	return result;
}

int CreateDirectory(const char *filename, void *stuff)
{
	return 1 + mkdir(filename, 0777);
}

int ilth(int otherInt)
{
    return CFSwapInt32LittleToHost(otherInt);
}

short slth(short otherShort)
{
    return CFSwapInt16LittleToHost(otherShort);
}

int ifls(const unsigned char *buffer)
{
    int data;
    memcpy(&data, buffer, 4);
    return CFSwapInt32LittleToHost(data);
}